package com.example.friend.controller.user;

import com.example.common.core.constants.HttpConstants;
import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.R;
import com.example.common.core.domain.TableDataInfo;
import com.example.friend.aspect.CheckUserStatus;
import com.example.friend.domain.exam.dto.ExamDTO;
import com.example.friend.domain.exam.dto.ExamQueryDTO;
import com.example.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {


    @Autowired
    private IUserExamService examService;



    // 我的竞赛列表
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return examService.list(examQueryDTO);
    }
    // 竞赛报名
    @CheckUserStatus
    @PostMapping("/enter")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token,@RequestBody ExamDTO examDTO) {
        return toR(examService.enter(token,examDTO.getExamId()));
    }
}
